package com.wc.AlgoOJ.LQ1036T.Q2025.Answer;

import java.util.Scanner;

public class Main {
    static int n, k, ans = 0;

    //检查是不是带有2 或 4
    static Boolean check(int parm) {
        while (parm > 0) {
            int t = parm % 10;
            if (t == 2 || t == 4) return true;
            parm /= 10;
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        n = 2500;
        k = 10;
        int mod = (int) (1e9 + 7);
        int[][] dp = new int[k + 1][n + 1];
        for (int i = 1; i <= n; i++) dp[1][i] = 1;
        for (int i = 1; i <= k; i++) {//10 遍历规模
            for (int j = 1; j <= n; j++) {//2500 遍历限制
                for (int q = 1; q <= j; q++) {//
                    dp[i][j] += dp[i - 1][j - q];
                    dp[i][j] %= mod;
                }
            }
        }
        while (t-- > 0) {
            n = scanner.nextInt();
            k = scanner.nextInt();
            long ans = 0;
            ans = dp[k][n];
            System.out.println(ans);
        }
    }
}